Plotly, Bokeh, Tableau may not be Visible.
import pandas as pd
# List1
lst = [['Trivandrum', 8.5241, 76.9366],
['Delhi', 28.7041, 77.1025],
['Himachal Pradesh', 31.1048, 77.1734],
['Pune', 18.5204, 73.8567],
['Peruvallur', 11.1053, 75.9330]]
df_india = pd.DataFrame(lst, columns =["City", "Latitude", "Longitude" ])
df_india
import plotly.graph_objects as go
mapbox_access_token = "pk.eyJ1IjoiYXRodWxtYXRoZXdrb25vb3IiLCJhIjoiY2ttazMyY2w4MGQxcDJucGh3NzJteHdrbyJ9.0-RxoHvUceNoUgvrOU17Dg"
fig = go.Figure(go.Scattermapbox(
lat=df_india["Latitude"],
lon=df_india["Longitude"],
mode='markers',
marker=go.scattermapbox.Marker(
size=14
),
text=df_india["City"],
))
fig.update_layout(
hovermode='closest',
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=go.layout.mapbox.Center(
lat=20,
lon=78
),
pitch=0,
zoom=2.5
)
)
fig.show()
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
url = "https://raw.githubusercontent.com/toshihiroryuu/Dataset-test/main/RidingMowers.csv"
df = pd.read_csv(url)
df.head(5)
df_own = df[df['Ownership'] == "Owner"]
df_own.head(5)
df_nown = df[df['Ownership'] != "Owner"]
df_nown
import matplotlib.pyplot as plt
plt.figure(figsize = (12,6))
plt.style.use('seaborn-whitegrid')
plt.title("Lot Size vs Income")
own = plt.scatter("Lot_Size", "Income", c ="yellow",
linewidths = 2, edgecolor ="grey", marker ="x",
s = 50, data = df_own)
nown = plt.scatter("Lot_Size", "Income", c ="red",
linewidths = 2, edgecolor ="blue",
s = 50, alpha = 1, data = df_nown)
plt.xlabel('Lot Size')
plt.ylabel('Income')
plt.legend((own, nown), ('Owner', 'Non-Owner'),
scatterpoints = 1, loc = 'lower right',
ncol = 3, fontsize = 16)
plt.show()
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
url = "https://raw.githubusercontent.com/kwartler/Harvard_DataMining_Business_Student/master/BookDataSets/LaptopSalesJanuary2008.csv"
df = pd.read_csv(url)
df.head(5)
store_listt = df['Store Postcode'].unique()
store_listt
df_store = df.groupby(['Store Postcode']).mean()
df_store.head(5)
import numpy as np
import matplotlib.pyplot as plt
courses = store_listt
values = list(df_store["Retail Price"])
fig = plt.figure(figsize = (10, 5))
plt.bar(courses, values, color ='blue',
width = 0.4)
plt.xticks(rotation = 45)
plt.xlabel("Stores")
plt.ylabel("Average Retail Price")
plt.title("Store vs Average Retail Price")
plt.show()
sorted_df = df_store["Retail Price"].sort_values()
sorted_df
Store with Pin code : N17 6QA has the largest Average Retail Price(494.63).
sorted_df
Store with Pin code : W4 3PH has the lowest Average Retail Price(481).
import plotly.express as px
px.box(df, x="Store Postcode", y="Retail Price")
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
url = "https://raw.githubusercontent.com/toshihiroryuu/Dataset-test/main/ApplianceShipments.csv"
df = pd.read_csv(url, usecols = [0, 1])
df.head(5)
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 6))
plt.plot(df.Quarter, df.Shipments, color='magenta', marker='x', linestyle='dashed')
plt.xticks(rotation = 45)
plt.xlabel("Quarter")
plt.ylabel("Shipments")
plt.title("Quarter vs Shipments")
plt.show()
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 8))
plt.plot(df.Quarter, df.Shipments, color='magenta', marker='x', linestyle='dashed')
plt.xticks(rotation = 45)
plt.ylim=[3500, 5000]
plt.xlabel("Quarter")
plt.ylabel("Shipments")
plt.title("Quarter vs Shipments")
plt.show()
Yes, There is an Quartery pattern in the plot.
Total shipments increase in Q1 and Q2, while it decrease in the next two Quarters(Q3 and Q4).
quar_list = df.Quarter.tolist()
quar_label =[]
year_label = []
for ele in quar_list:
quar_label.append(ele.split("-")[0])
year_label.append(ele.split("-")[1])
df["Quarter_label"] = quar_label
df["Year_label"] = year_label
df.head(5)
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
plt.figure(figsize=(12, 6))
q1 = plt.plot(df.Year_label[df.Quarter_label=="Q1"], df.Shipments[df.Quarter_label=="Q1"],
color='magenta', marker='x', linestyle='dashed')
q2 = plt.plot(df.Year_label[df.Quarter_label=="Q2"], df.Shipments[df.Quarter_label=="Q2"],
color='green', marker='x', linestyle='dashed')
q3 = plt.plot(df.Year_label[df.Quarter_label=="Q3"], df.Shipments[df.Quarter_label=="Q3"],
color='blue', marker='x', linestyle='dashed')
q4 = plt.plot(df.Year_label[df.Quarter_label=="Q4"], df.Shipments[df.Quarter_label=="Q4"],
color='yellow', marker='x', linestyle='dashed')
plt.xticks(rotation = 45)
plt.ylim=[3500, 5000]
plt.xlabel("Year", fontsize=16)
plt.ylabel("Shipments", fontsize=16)
plt.title("Year vs Shipments", fontsize=16)
q1_patch = mpatches.Patch(color='magenta', label='Quarter 1')
q2_patch = mpatches.Patch(color='green', label='Quarter 2')
q3_patch = mpatches.Patch(color='blue', label='Quarter 3')
q4_patch = mpatches.Patch(color='yellow', label='Quarter 4')
plt.legend(handles=[q1_patch, q2_patch, q3_patch, q4_patch], fontsize=14)
plt.show()
Quarter2 (Q2) always had an increease in shipment compared to previous years.
Quarter3 (Q3) had the highest shipment in the year 1986, but Quarter(Q2) has the highest shipment for all other years.
Quarter4 (Q4) has the lowest shipment througout the years except the year 1989.
Quarter1 and Quarter4 (Q1 and Q4) has lowest shipments than Q2 and Q3.
df_yr = df.groupby("Year_label").sum()
df_yr
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 8))
plt.plot(df_yr, color='red', marker='x', linestyle='dashed')
plt.xticks(rotation = 45)
plt.xlabel("Year", fontsize=16)
plt.ylabel("Total Shipments", fontsize=16)
plt.title("Year vs Total Shipments", fontsize=16)
plt.show()
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
url = "https://raw.githubusercontent.com/toshihiroryuu/Dataset-test/main/Credit.csv"
df = pd.read_csv(url)
df.head(5)
import plotly.express as px
fig = px.bar(df, x='Age', y='Balance')
fig.show()
import plotly.express as px
fig = px.sunburst(df, path=["Gender", "Ethnicity", "Student", "Married"], values='Income')
fig.show()
import plotly.express as px
import plotly.graph_objects as go
fig = go.Figure(data=[go.Scatter(
x=df["Age"], y=df["Rating"],
mode='markers', marker_size=df["Cards"])
])
fig.show()
import plotly.express as px
fig = px.pie(df, values=df["Cards"], names=df["Gender"], color_discrete_sequence=px.colors.sequential.RdBu)
fig.show()
import plotly.express as px
fig = px.scatter(df, x="Age", y="Income")
fig.show()
# Show Output inline jupyter notebook
from bokeh.io import output_notebook
output_notebook()
from bokeh.plotting import figure, show
p = figure(tooltips=[("x", "$x"), ("y", "$y")])
p.x_range.range_padding = p.y_range.range_padding = 0
p.circle(x="Age", y="Income", source=df,
size=10, color='Blue')
p.grid.grid_line_width = 0.5
p.title.text ='Age vs Income - Scatter Plot'
p.xaxis.axis_label = 'Age'
p.yaxis.axis_label = 'Income'
show(p)
import pandas as pd
url = "https://raw.githubusercontent.com/toshihiroryuu/Dataset-test/main/Minard_temp.csv"
df = pd.read_csv(url)
df.rename(columns = {'Unnamed: 0':'ID'}, inplace = True)
df.head(5)
from bokeh.plotting import figure, show
s = figure(tooltips=[("x", "$x"), ("y", "$y")])
s.x_range.range_padding = p.y_range.range_padding = 0
s.vbar(x='ID', top='long', source=df, width=0.70)
s.title.text ='ID vs Long - Bar Chart'
s.xaxis.axis_label = 'ID'
s.yaxis.axis_label = 'Long'
show(s)
from bokeh.plotting import figure, show
k = figure(tooltips=[("x", "$x"), ("y", "$y")], plot_width=600, plot_height=300)
k.line(df.ID, df.long, line_width=2)
k.title.text ='ID vs Long - Line Plot'
k.xaxis.axis_label = 'ID'
k.yaxis.axis_label = 'Long'
show(k)
from bokeh.plotting import figure, show
t = figure(tooltips=[("x", "$x"), ("y", "$y")], plot_width=600, plot_height=300)
t.varea(x = df.ID, y1 = df.long, fill_color="green")
t.title.text ='ID vs Long - Area Plot'
t.xaxis.axis_label = 'ID'
t.yaxis.axis_label = 'Long'
show(t)
from bokeh.plotting import figure, show
j = figure(plot_width=600, plot_height=300)
j.step(df.ID, df.long, line_width=2, mode="center")
j.title.text ='ID vs Long - Step Plot'
j.xaxis.axis_label = 'ID'
j.yaxis.axis_label = 'Long'
show(j)
Please find the tableau dash board at : https://public.tableau.com/views/InsuranceAnalysis_16163072902500/Dashboard1?:language=en&:display_count=y&publish=yes&:origin=viz_share_link
or
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512406146' style='position: relative'>
<noscript><a href='#'><img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Age/1_rss.png' style='border: none' /></a></noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/Age' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' /
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Age/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512406146');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512445707' style='position: relative'><noscript><a href='#'>
<img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/AgevsBMIScatterplot/1_rss.png' style='border: none' /></a>
</noscript><object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/AgevsBMIScatterplot' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/AgevsBMIScatterplot/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512445707');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512465515' style='position: relative'>
<noscript><a href='#'>
<img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/AgevsSmoking/1_rss.png' style='border: none' /></a>
</noscript>
<object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/AgevsSmoking' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/AgevsSmoking/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512465515');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512491809' style='position: relative'><noscript><a href='#'>
<img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/ChildrenvsMaxcharges/1_rss.png' style='border: none' /></a>
</noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/ChildrenvsMaxcharges' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/ChildrenvsMaxcharges/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512491809');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512513870' style='position: relative'>
<noscript><a href='#'>
<img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/BMIvsCharges/1_rss.png' style='border: none' />
</a></noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/BMIvsCharges' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/BMIvsCharges/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512513870');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512536878' style='position: relative'>
<noscript><a href='#'>
<img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Region/1_rss.png' style='border: none' /></a>
</noscript>
<object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/Region' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Region/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512536878');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512586269' style='position: relative'>
<noscript><a href='#'><img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Map/1_rss.png' style='border: none' /></a>
</noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/Map' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Map/1.png' /> <param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512586269');
var vizElement = divElement.getElementsByTagName('object')[0];
vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
HTML Embeddings
%%HTML
<div class='tableauPlaceholder' id='viz1616512643321' style='position: relative'>
<noscript><a href='#'><img alt=' ' src='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Dashboard1/1_rss.png' style='border: none' /></a></noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='InsuranceAnalysis_16163072902500/Dashboard1' />
<param name='tabs' value='yes' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/In/InsuranceAnalysis_16163072902500/Dashboard1/1.png' /> <param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1616512643321');
var vizElement = divElement.getElementsByTagName('object')[0];
if ( divElement.offsetWidth > 800 ) { vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';} else { vizElement.style.width='100%';vizElement.style.minHeight='1850px';vizElement.style.maxHeight=(divElement.offsetWidth*1.77)+'px';}
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>